﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;

namespace Ghostify {
	public static class App {
		public static BackgroundWorker musicWorker = new BackgroundWorker();
		public static int song = 0;

		public static string[] neninona = new string[] {
			"C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16",
			"B-4-4", "B-4-4", "B-4-8",
			"C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16", "C-5-16",
			"D-5-4", "D-5-4", "D-5-8",
			"D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16",
			"C-5-4", "C-5-4", "C-5-8",
			"D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16", "D-5-16",
			"E-5-4", "E-5-4", "E-5-8",
		};

		public static string[] nainonaino = new string[] {
			"C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", 
			"B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", 
			"C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", 
			"B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", 

			"C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", 
			"B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", 
			"C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", "C-5-32", "D-5-32", "E-5-32", 
			"B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", "B-4-32", "C-5-32", "D-5-32", 
		};

		public static string[] nananino = new string[] {
			"C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", 
			"C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", 
			"B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", 
			"B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", 

			"C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", 
			"C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", "C-5-16", "D-5-16", 
			"B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", 
			"B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", "B-4-16", "D-5-16", 

			"C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", 
			"C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", 
			"B-4-16", "E-5-16", "B-4-16", "E-5-16", "B-4-16", "E-5-16", "B-4-16", "E-5-16", 
			"B-4-16", "E-5-16", "B-4-16", "E-5-16", "B-4-16", "E-5-16", "B-4-16", "E-5-16", 

			"C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", 
			"C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", "C-5-16", "E-5-16", 
			"F-4-16", "F-5-16", "B-4-16", "F-5-16", "B-4-16", "F-5-16", "B-4-16", "F-5-16", 
			"B-4-16", "F-5-16", "B-4-16", "F-5-16", "B-4-16", "F-5-16", "B-4-16", "F-5-16", 
		};

		public static string[] nananono = new string[] {
			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",

			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",

			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",

			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "B-4-16", "B-4-16", "C-5-16", "C-5-16", "B-4-16", "B-4-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",
			"C-5-16", "C-5-16", "D-5-16", "D-5-16", "C-5-16", "C-5-16", "D-5-16", "D-5-16",
		};

		public static int GetRandom(int min = 0x00, int max = 0xFF) {
			return new Random((int)DateTime.Now.Ticks).Next(min, max);
		}

		public static string[] GetRandomSong(int song) {
			switch (song) {
				case 0:
					return nananino;

				case 1:
					return nainonaino;

				case 2:
					return nananono;

				case 3:
					return nainonaino;

				case 4:
					return nananino;

				default:
					return nananono;
			}
		}

		[STAThread]
		public static void Main(string[] args) {
			// Music worker.
			musicWorker.DoWork += (sender, eventArgs) => {
				while (true) {
					Tones.PlaySong(String.Join(",", GetRandomSong(song)));
					song++;
				}
			};

			musicWorker.RunWorkerAsync();
			
			Application.Run(new ViewWindow());
		}
	}
}
